﻿using ComLib.ComType;
using ComUIControl;
using KCommon;
using KeyboardArg;
using KeyboardFactory;
using KInterfaces;
using KXmlUIControl;
using KXmlUIControl.KControl;
using LogLib;
using Mp3Player;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Action = System.Action;
using Button = System.Windows.Forms.Button;
using KeyBoardArgs = KeyboardArg.KeyBoardArgs;
using Label = System.Windows.Forms.Label;
using SendMessageType = KeyboardArg.SendMessageType;
using TextBox = System.Windows.Forms.TextBox;

namespace KWindow.KPageCore
{
    public partial class PageControlBase : UserControl
    {     
        #region keyboardEventHandler
        public event KeyboardPopupEventHandler KeyboardPopup;
        protected void OnKeyboardPopup(KeyBoardArgs args, System.Drawing.Rectangle screenRect)
        {
            if (KeyboardPopup != null)
            {
                KeyboardPopup(this, new KeyboardPopupEventArgs(args), screenRect);
            }
        }
        #endregion
     
        public string LanguageCode { get; set; }

        public XmlConfigForm UIConfig { set; get; } = null;

        public string HandleId { get; protected set; }

        public PageControlBase()
        {
            InitializeComponent();
        }

        public string GetAppName()
        {
            return Path.GetFileNameWithoutExtension(this.GetType().Assembly.CodeBase);
        }

        public string GetAssemblyDirectory()
        {
            Assembly ass = this.GetType().Assembly;
            string directory = Path.GetDirectoryName(ass.CodeBase);
            if(directory.StartsWith("file:\\"))
            {
                directory = directory.Substring(6);
            }          
            return directory;
        }

    }
}
